<?php

/**
 * This is the model class for table "cpanel_accounts".
 *
 * The followings are the available columns in table 'cpanel_accounts':
 * @property integer $id_cpanel_accounts
 * @property integer $id_account
 * @property string $domain
 * @property string $IP
 * @property string $username
 * @property string $setup_date
 * @property string $quota
 * @property string $disk_used
 * @property string $package
 * @property string $theme
 * @property string $owner
 * @property string $last_backup
 */
class CpanelAccounts extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return CpanelAccounts the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cpanel_accounts';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_account', 'numerical', 'integerOnly'=>true),
			array('domain, IP, username, setup_date, quota, disk_used, package, theme, owner, last_backup', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_cpanel_accounts, id_account, domain, IP, username, setup_date, quota, disk_used, package, theme, owner, last_backup', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'WhmAccount' => array(self::BELONGS_TO, 'WhmAccount', 'id_account'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_cpanel_accounts' => 'Id Cpanel Accounts',
			'id_account' => 'Id Account',
			'domain' => 'Domain',
			'IP' => 'Ip',
			'username' => 'Username',
			'setup_date' => 'Setup Date',
			'quota' => 'Quota',
			'disk_used' => 'Disk Used',
			'package' => 'Package',
			'theme' => 'Theme',
			'owner' => 'Owner',
			'last_backup' => 'Last Backup',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_cpanel_accounts',$this->id_cpanel_accounts);
		$criteria->compare('id_account',$this->id_account);
		$criteria->compare('domain',$this->domain,true);
		$criteria->compare('IP',$this->IP,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('setup_date',$this->setup_date,true);
		$criteria->compare('quota',$this->quota,true);
		$criteria->compare('disk_used',$this->disk_used,true);
		$criteria->compare('package',$this->package,true);
		$criteria->compare('theme',$this->theme,true);
		$criteria->compare('owner',$this->owner,true);
		$criteria->compare('last_backup',$this->last_backup,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}